﻿<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8"/>
    <title>SuperMgr前端框架</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>

    <!--全局通用框架样式 begin-->
    <!-- 全局基本样式 -->
    <link href="../content/superui/min/css/superui.common.min.css" rel="stylesheet"/>
    <!-- 全局主题样式 -->
    <link href="../content/superui/global/css/components.min.css" id="style_components" rel="stylesheet"/>
    <link href="../content/superui/pages/layouts/css/themes/darkblue.min.css" rel="stylesheet" type="text/css" id="style_color"/>
    <link href="../content/plugins/jqgrid/jqgrid.css" rel="stylesheet"/>
    <script src="../content/superui/min/js/superui.common.min.js"></script>

    <script src="../content/supermgr/js/common.js"></script>
    <link href="../content/supermgr/css/common.css" rel="stylesheet" />
    <link href="../content/plugins/dialog/dialog.css" rel="stylesheet" />
    <!--全局通用框架样式 end-->
    <style>
      
    </style>
</head>
<body>
    <div class="page-container">
        <div class="page-content">

                <div class="titlePanel">
                    <div class="title-search">
                        <table>
                            <tr>
                                <td>
                                    <div class="btn-group">
                                        <button aria-expanded="false" class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
                                            选择条件
                                            <i class="fa fa-angle-down"></i>
                                        </button>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a data-value="Account">账户</a></li>
                                            <li><a data-value="RealName">姓名</a></li>
                                            <li><a data-value="Mobile">手机</a></li>
                                        </ul>
                                    </div>

                                </td>
                                <td style="padding-left: 2px;">
                                    <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
                                </td>
                                <td style="padding-left: 5px;">
                                    <a id="btn_Search" class="btn btn-primary btn-sm"><i class="fa fa-search"></i>&nbsp;查询</a>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="toolbar">
                        <div class="btn-group">
                            <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                            <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
                            <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
                            <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
                            <a id="lr-revisepassword" class="btn btn-default" onclick="btn_revisepassword()"><i class="fa fa-key"></i>&nbsp;重置密码</a>
                            <a id="lr-more" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                <i class="fa fa-reorder"></i>&nbsp;更多<span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu pull-right">
                                <li id="lr-export"><a onclick="btn_export()"><i></i>&nbsp;导出Excel</a></li>
                                <li id="lr-disabled"><a onclick="btn_disabled()"><i></i>&nbsp;禁用账户</a></li>
                                <li id="lr-enabled"><a onclick="btn_enabled()"><i></i>&nbsp;启用账户</a></li>
                            </ul>
                        </div>
                        <div class="btn-group">
                            <a id="lr-authorize" class="btn btn-default" onclick="btn_authorize()"><i class="fa fa-gavel"></i>&nbsp;用户权限</a>
                            <a id="lr-appfilter" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                <i class="fa fa-filter"></i>&nbsp;访问过滤<span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu pull-right">
                                <li id="lr-ipfilter"><a onclick="btn_ipfilter()"><i></i>&nbsp;IP过滤</a></li>
                                <li id="lr-timefilter"><a onclick="btn_timefilter()"><i></i>&nbsp;时段过滤</a></li>
                            </ul>
                        </div>

                    </div>
                </div>
                <div class="gridPanel">
                    <table id="gridTable"></table>
                    <div id="gridPager"></div>
                </div>
            </div>
        
    </div>
</body>
<!--[if lt IE 9]>
    <script src="../content/superui/base/base-core/excanvas.min.js"></script>
    <script src="../content/superui/base/base-core/respond.min.js"></script>
<![endif]-->
<!-- 全局公共类库Begin -->

</html>

<script>
    $(function() {
        //InitialPage();
        GetGrid();
    });

//初始化页面
    function InitialPage() {
        //resize重设(表格、树形)宽高
        $(window).resize(function(e) {
            window.setTimeout(function() {
                $('#gridTable').setGridWidth(($('.gridPanel').width()));
               // $("#gridTable").setGridHeight($(window).height() - 136.5);
                
            }, 200);
            e.stopPropagation();
        });
    }

//加载表格
    function GetGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable');
        $gridTable.jqGrid({
            url: "../content/supermgr/json/userdata.json",
            datatype: "json",
            height: App.getViewPort().height - $('.page-footer').outerHeight() - $('.page-header').outerHeight(),//$(window).height() - 136.5,
            colModel: [
                { label: '主键', name: 'F_UserId', hidden: true },
                { label: '账户', name: 'F_Account', index: 'F_Account', width: 100, align: 'left' },
                { label: '姓名', name: 'F_RealName', index: 'F_RealName', width: 100, align: 'left' },
                {
                    label: '性别',
                    name: 'F_Gender',
                    index: 'F_Gender',
                    width: 45,
                    align: 'center',
                    formatter: function(cellvalue, options, rowObject) {
                        return cellvalue == 1 ? "男" : "女";
                    }
                },
                { label: '手机', name: 'F_Mobile', index: 'F_Mobile', width: 100, align: 'center' },
                {
                    label: '公司',
                    name: 'F_OrganizeId',
                    index: 'F_OrganizeId',
                    width: 200,
                    align: 'left',
                    formatter: function(cellvalue, options, rowObject) {
                        return "母公司";
                    }
                },
                {
                    label: '部门',
                    name: 'F_DepartmentId',
                    index: 'F_DepartmentId',
                    width: 100,
                    align: 'left',
                    formatter: function(cellvalue, options, rowObject) {
                        return "开发部";
                    }
                },
                { label: '岗位', name: 'F_DutyName', index: 'F_DutyName', width: 100, align: 'left' },
                { label: '职位', name: 'F_PostName', index: 'F_PostName', width: 100, align: 'left' },
                {
                    label: '角色',
                    name: 'F_RoleId',
                    index: 'F_RoleId',
                    width: 100,
                    align: 'left',
                    formatter: function(cellvalue, options, rowObject) {
                        return "管理员";
                    }
                },
                { label: '主管', name: 'F_Manager', index: 'F_Manager', width: 100, align: 'left' },
                {
                    label: "状态",
                    name: "F_EnabledMark",
                    index: "F_EnabledMark",
                    width: 50,
                    align: "center",
                    formatter: function(cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return '<span onclick=\"btn_disabled(\'' + rowObject.UserId + '\')\" class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
                        } else if (cellvalue == 0) {
                            return '<span onclick=\"btn_enabled(\'' + rowObject.UserId + '\')\" class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
                        }
                    }
                },
                { label: "备注", name: "F_Description", index: "F_Description", width: 200, align: "left" }
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'F_OrganizeId asc,F_CreateDate desc',
            rownumbers: true,
            autowidth: true,
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function() {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function() {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
       
        //查询条件
        $("#queryCondition .dropdown-menu li").click(function() {
            var text = $(this).find('a').html();
            var value = $(this).find('a').attr('data-value');
            $("#queryCondition .dropdown-text").html(text).attr('data-value', value);
        });
        //查询事件
        $("#btn_Search").click(function() {
            var queryJson = {
                condition: $("#queryCondition").find('.dropdown-text').attr('data-value'),
                keyword: $("#txt_Keyword").val()
            }
            $gridTable.jqGrid('setGridParam', {
                postData: { queryJson: JSON.stringify(queryJson) },
                page: 1
            }).trigger('reloadGrid');
        });
        //查询回车
        $('#txt_Keyword').bind('keypress', function(event) {
            if (event.keyCode == "13") {
                $('#btn_Search').trigger("click");
            }
        });
    }

//新增
    function btn_add() {
        $.fn.modalOpen({
            id: "Form",
            title: '添加用户',
            url: 'adduser.html',
            width: "750px",
            height: "550px",
            callBack: function(iframeId) {
                top.frames[iframeId].AcceptClick();
            }
        });
    };

//编辑
    function btn_edit() {
        var keyValue = $("#gridTable").jqGridRowValue("F_UserId");
        if (checkedRow(keyValue)) {
            $.fn.modalOpen({
                id: "Form",
                title: '修改用户',
                url: 'adduser.html' ,
                width: "750px",
                height: "550px",
                callBack: function(iframeId) {
                    top.frames[iframeId].AcceptClick();
                }
            });
        }
    }

//删除
    function btn_delete() {
        var keyValue = $("#gridTable").jqGridRowValue("F_UserId");
        if (keyValue) {
            $.fn.deleteForm({
                url: "../../BaseManage/User/RemoveForm",
                param: { keyValue: keyValue },
                success: function(data) {
                    $("#gridTable").trigger("reloadGrid");
                }
            })
        } else {
            dialogMsg('请选择需要删除的用户！', 0);
        }
    }


//用户授权
    function btn_authorize() {
        var keyValue = $("#gridTable").jqGridRowValue("F_UserId");
        var RealName = $("#gridTable").jqGridRowValue("F_RealName");
        if (checkedRow(keyValue)) {
            $.fn.modalOpen({
                id: "AllotAuthorize",
                title: '用户授权 - ' + RealName,
                url: 'permissionUser.html',
                width: "700px",
                height: "690px",
                btn: null
            });
        }
    }

//IP过滤
    function btn_ipfilter() {
        var keyValue = $("#gridTable").jqGridRowValue("F_UserId");
        var FullName = $("#gridTable").jqGridRowValue("F_RealName");
        if (checkedRow(keyValue)) {
            $.fn.modalOpen({
                id: "FilterIP",
                title: 'TCP/IP 地址访问限制 - ' + FullName,
                url: '/AuthorizeManage/FilterIP/Index?objectId=' + keyValue + '&objectType=Uesr',
                width: "600px",
                height: "400px",
                btn: null
            });
        }
    }

</script>
<script src="../content/plugins/jqgrid/grid.locale-cn.js"></script>
<script src="../content/plugins/jqgrid/jqgrid.min.js"></script>
<script src="../content/plugins/dialog/dialog.js"></script>